﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>用户登录</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="css/demo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
	width: 100%;
	height: 100%;
	margin: 0;
	overflow: hidden;
}
</style>
<script src="js/jquery/boot.js" type="text/javascript"></script>
<script type="text/javascript">
	if(top != window){
	   top.location = "login.html"
	}
</script>

</head>
<body onload="document.getElementById('username$text').focus()">
<div id="loginWindow" class="mini-window" title="用户登录"
	style="width: 350px; height: 165px;" showModal="true"
	showCloseButton="false">

<div id="loginForm" style="padding: 15px; padding-top: 10px;">
<table>
	<tr>
		<td style="width: 60px;"><label for="username$text">用户名：</label></td>
		<td><input id="username" name="username"
			onvalidation="onUserNameValidation" class="mini-textbox"
			requiredErrorText="用户名不能为空" required="true" style="width: 150px;" /></td>
	</tr>
	<tr>
		<td style="width: 60px;"><label for="password$text">密&nbsp;&nbsp;&nbsp;码：</label></td>
		<td><input id="password" name="password"
			onvalidation="onPwdValidation" class="mini-password"
			requiredErrorText="密码不能为空" required="true" style="width: 150px;"
			onenter="onLoginClick" /> &nbsp;&nbsp;<a href="#">忘记密码?</a></td>
	</tr>
	<tr>
		<td></td>
		<td style="padding-top: 5px;"><a onclick="onLoginClick"
			class="mini-button" style="width: 60px;">登录</a> <a
			onclick="onResetClick" class="mini-button" style="width: 60px;">重置</a>
		</td>
	</tr>
</table>
</div>

</div>

<script type="text/javascript">
        mini.parse();

        var loginWindow = mini.get("loginWindow");
        loginWindow.show();

        window.onresize = function () {
        
            loginWindow.show();
        }

        function onLoginClick(e) {
            var form = new mini.Form("#loginWindow");

            form.validate();
            if (form.isValid() == false) return;
            var o = form.getData(); 
            var json = mini.encode(o);

            $.ajax({
                url: "login/login.jsps",
                data: { loginInfo: json },
                cache: false,
                success: function (text) {
                	if (text == "" || typeof(text) == 'object') {
                		 loginWindow.hide();
                         mini.loading("登录成功，正在进入系统...", "登录成功");
                         setTimeout(function () {
                             window.location = "index.html";
                         }, 1500);
                	} else {
                		var error = mini.decode(text);
                		mini.alert(error.error);
                   	}
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }
        function onResetClick(e) {
            var form = new mini.Form("#loginWindow");
            form.clear();
            document.getElementById('username$text').focus();
        }
        /////////////////////////////////////
        function isEmail(s) {
            if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
                return true;
            else
                return false;
        }
        function onUserNameValidation(e) {
            if (e.isValid) {
                if (e.value.length < 1) {
                    e.errorText = "用户名不能为空";
                    e.isValid = false;
                }
            }
        }
        function onPwdValidation(e) {
            if (e.isValid) {
                if (e.value.length < 1) {
                    e.errorText = "密码不能为空";
                    e.isValid = false;
                }
            }
        }
    </script>

</body>
</html>